import requests

from public.Getip import getProxy


def httpGet(geturl, referer, session_cookies, mobile, tid):
    payload = {}
    headers = {
        'authority': 'creator.xiaohongshu.com',
        'accept': 'application/json, text/plain, */*',
        'accept-language': 'zh-CN,zh;q=0.9',
        'authorization': '',
        'referer': referer,
        'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"',
        'sec-ch-ua-mobile': '?0',
        'sec-ch-ua-platform': '"Windows"',
        'sec-fetch-dest': 'empty',
        'sec-fetch-mode': 'cors',
        'sec-fetch-site': 'same-origin',
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
    }
    proxy_ip = getProxy(mobile, tid)
    proxies = {"http": "http://"+proxy_ip, "https": "http://"+proxy_ip}
    response = requests.request("GET", geturl, headers=headers, data=payload, cookies=session_cookies, proxies=proxies)
    # print(response.text)
    return response.text


